<?php 
require_once $_SERVER['DOCUMENT_ROOT'].'/inc/core/env.inc.php';

$return['success'] = false; 
$return['html'] = null;
$return['error'] = null;

if ($_USER->login) {
	$return['success'] = true;
	$return['html'] = file_get_contents($_SITE['path']['dir']['blocks']['containers']['admin'].'/admin-rows.tag.html');
	
	$rowLog = file_get_contents($_SITE['path']['dir']['blocks']['containers']['admin'].'/admin-row.tag.html');
	$col = file_get_contents($_SITE['path']['dir']['blocks']['containers']['admin'].'/admin-col.tag.html');
	
	$sql = 'SELECT * FROM '.$_DB->getPrefix().'log ORDER BY date_in DESC';
	$res = $_DB->query($sql);
	$rows = '<li><div><b>Date</b></div><div><b>Class</b></div><div><b>File</b></div><div><b>Log</b></div><br class="clearboth"></li>';
	$rowClass = 'row-gray';
	foreach ($res as $ele) {
			
		$description = str_replace($_TAGS["share-content-col"], (empty($ele['date_in']) ?  '&nbsp;' : $ele['date_in']), $col);
		$description .= str_replace($_TAGS["share-content-col"], (empty($ele['class']) ?  '&nbsp;' : $ele['class']), $col);
		$description .= str_replace($_TAGS["share-content-col"], (empty($ele['file']) ?  '&nbsp;' : $ele['file']), $col);
		$description .= str_replace($_TAGS["share-content-col"], (empty($ele['description']) ?  '&nbsp;' : $ele['description']), $col);
				
		if ($rowClass == 'row-gray') {
			$rowClass = 'row-white';
		} else {
			$rowClass = 'row-gray';
		}
		
		$row = str_replace($_TAGS['admin-row-class'], $rowClass, $rowLog);
		$rows .= str_replace($_TAGS['share-content-columns'], $description, $row);
	}
	
	$return['html'] = str_replace($_TAGS['admin-rows'], $rows, $return['html']);
	
} else {
	$return['error'] = $_TRANSLATE->traslate('{VOCABULARY|permission_disactive}', $_SESSION['LANGUAGE']);
}

echo '('.json_encode($return).')';
?>